<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改置换信息表" bodyClass="white-bg" />
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-substitution-edit"  class="form-horizontal">
    <input name="id" value="${bpmCrmSubstitution.id}" type="hidden">
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "销售员" />：                               <i class="fa fa-question-circle-o" title="销售员"></i>                                
       </label>
        <div class="col-sm-8"><input name="saleUserid" value="${bpmCrmSubstitution.saleUserid?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "销售订单编号" />：                               <i class="fa fa-question-circle-o" title="销售订单编号"></i>                                
       </label>
        <div class="col-sm-8"><input name="saleOrderNumber" value="${bpmCrmSubstitution.saleOrderNumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车辆识别号" />：                               <i class="fa fa-question-circle-o" title="车辆识别号"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVin" value="${bpmCrmSubstitution.outCarVin?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车型" />：                               <i class="fa fa-question-circle-o" title="车型"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVehicle" value="${bpmCrmSubstitution.outCarVehicle?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "换入车辆识别号" />：                               <i class="fa fa-question-circle-o" title="换入车辆识别号"></i>                                
       </label>
        <div class="col-sm-8"><input name="inCarVin" value="${bpmCrmSubstitution.inCarVin?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "换入车辆/车型" />：                               <i class="fa fa-question-circle-o" title="换入车辆/车型"></i>                                
       </label>
        <div class="col-sm-8"><input name="inCarVehicle" value="${bpmCrmSubstitution.inCarVehicle?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车辆里程" />：                               <i class="fa fa-question-circle-o" title="车辆里程"></i>                                
       </label>
        <div class="col-sm-8"><input name="inCarMileage" value="${bpmCrmSubstitution.inCarMileage?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "要价/置换价" />：                               <i class="fa fa-question-circle-o" title="要价/置换价"></i>                                
       </label>
        <div class="col-sm-8"><input name="inCarAskprice" value="${bpmCrmSubstitution.inCarAskprice?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "折价备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="inCarTradememo" class="form-control">${bpmCrmSubstitution.inCarTradememo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "审核备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="purchaseRemark" class="form-control">${bpmCrmSubstitution.purchaseRemark?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "是否收购"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="purchaseIsbuy" dictType="sys_crm_isOrNo" value="${bpmCrmSubstitution.purchaseIsbuy?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "估价" />：                               <i class="fa fa-question-circle-o" title="采购经理-估价"></i>                                
       </label>
        <div class="col-sm-8"><input name="purchaseEvaluation" value="${bpmCrmSubstitution.purchaseEvaluation?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "入库检查"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="warehouseInCheck" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.warehouseInCheck?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "入库估价" />：                               <i class="fa fa-question-circle-o" title="库管-入库估价"></i>                                
       </label>
        <div class="col-sm-8"><input name="warehouseInEvaluation" value="${bpmCrmSubstitution.warehouseInEvaluation?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "入库备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="warehouseInRemark" class="form-control" required>${bpmCrmSubstitution.warehouseInRemark?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "入库文件"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="warehouseInFile" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.warehouseInFile?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "入库文件路径" />：                
       </label>
        <div class="col-sm-8"><input name="filehumanInFilepath" value="${bpmCrmSubstitution.filehumanInFilepath?default("")}" class="form-control" type="text" >                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "入库备注" />：                               <i class="fa fa-question-circle-o" title="文件专员-入库备注"></i>                                
       </label>
        <div class="col-sm-8"><input name="filehumanInRemark" value="${bpmCrmSubstitution.filehumanInRemark?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="checkmoneyCashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.checkmoneyCashierReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "证明" />：                               <i class="fa fa-question-circle-o" title="证明（附件路径）"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyProofpath" value="${bpmCrmSubstitution.checkmoneyProofpath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款金额审核" />：                               <i class="fa fa-question-circle-o" title="贷款金额审核"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyLoanamountreceived" value="${bpmCrmSubstitution.checkmoneyLoanamountreceived?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收据编号" />：                               <i class="fa fa-question-circle-o" title="收据编号（需要校验是否重复）"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyReceiptnumber" value="${bpmCrmSubstitution.checkmoneyReceiptnumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳备注/备忘录"/>：</label>
        <div class="col-sm-8">
            <textarea name="checkmoneyMemo" class="form-control" required>${bpmCrmSubstitution.checkmoneyMemo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "订单生效日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="orderTakeEffectTime"  data-type="date"   value="${(bpmCrmSubstitution.orderTakeEffectTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收款日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="collectionTime"  data-type="date"   value="${(bpmCrmSubstitution.collectionTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "利息率" />：                               <i class="fa fa-question-circle-o" title="利息率（默认千分之八）"></i>                                
       </label>
        <div class="col-sm-8"><input name="interestRate" value="${bpmCrmSubstitution.interestRate?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "财务经理审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="financeManagerReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.financeManagerReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "经理复核" />：                               <i class="fa fa-question-circle-o" title="经理复核"></i>                                
       </label>
        <div class="col-sm-8"><input name="managerReview" value="${bpmCrmSubstitution.managerReview?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
</@form.form>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "bpm/substitution";
    $("#form-substitution-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        var newString =$('#form-substitution-edit').serialize();
        var intervalDay='';
        var orderTakeEffectTime=$("[name='orderTakeEffectTime']").val();
        var collectionTime=$("[name='collectionTime']").val();
        if(!isNullOrEmpty(orderTakeEffectTime)&&!isNullOrEmpty(collectionTime)){
            var timeSpan=new Date(collectionTime)-new Date(orderTakeEffectTime);
            intervalDay=Math.floor(timeSpan/(24*3600*1000)).toString();
        }
        var interestRate=$("[name='interestRate']").val();
        console.log("利息率",interestRate)
        var checkmoneyLoanamountreceived=$("[name='checkmoneyLoanamountreceived']").val();
        console.log("贷款金额",checkmoneyLoanamountreceived)
        var costOfCapital=parseFloat(checkmoneyLoanamountreceived)*parseInt(intervalDay)*parseFloat(interestRate);
        console.log("资金成本",costOfCapital.toFixed(4))
        console.log("赋值前对象的值为",newString)
        if(newString.includes("intervalDay")){
            newString=newString.replace("&intervalDay=",("&intervalDay="+intervalDay));
        }
        else{
            newString=newString+ "&intervalDay="+intervalDay;
        }
        if(newString.includes("costOfCapital")){
            newString=newString.replace("&costOfCapital=",("&costOfCapital="+costOfCapital.toFixed(4)));
        }
        else{
            newString=newString+ "&costOfCapital="+costOfCapital.toFixed(4);
        }
        console.log("赋值后的对象字符串的值为",newString)
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/edit",newString);
        }
    }
    function isNullOrEmpty(value) {
        return value==''||value==null||value==undefined;
    }

</script>
</@footer>
</@pageTheme>
